<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/list.css"/>">
	<script type="text/javascript" src="<c:url value="/js/jquery.js"/>"></script>
	<script type="text/javascript">
	 function del(no,name){
          if(confirm("确定要删除 "+name+" 商品吗?")){
            location.href="<c:url value="/goods?act=del&ctg_no="/>"+no;
          }
      }
      
      function mend(no){
          location.href="<c:url value="/goods?act=for_update&ctg_no="/>"+no;
      }
      
       //pageno 指定页码数
         function doQuery(pageno)
         {
           if(pageno<1 || pageno>${page.totalPageNum})
           {
              alert("页号超出范围，有效范围：[1-"+${page.totalPageNum}+"]!");
              ${'pageNo'}.select();
              return;
           }
           //location.href="<c:url value="/indentMgr?act=for_list"/>"+"&page_no="+pageno;
           document.forms[0].page_no.value=pageno;
           document.forms[0].submit();
         }
         function doQuery2(){
           
           var pageNo=document.getElementById("pageNo").value;
           doQuery(pageNo);
           
         }
         
         //控制键盘输入
         function onlynumber(){
		   if(event.keyCode==13)
			 return true;
		   if(event.keyCode<48||event.keyCode>57)
		   {
			 event.keyCode=0;
			 event.returnValue=false;
		   }
		   event.returnValue=true;
	     }
       //控制类别编号输入

       onsubmit=function(){
     //    	alert("ddd");
      	var sss=$(":input[name=ctg_no]").val();
     // 不可行   	var sss=document.getElementsByName("ctg_no").value;
         	if(isNaN(sss)){
	            alert("类别编号只能为数字!");
	            return false;
	        }
	     }  
      
	</script>

  </head>
  
  <body>
      <div class="wrapper_div">
          <span class="title">所有商品信息</span>
          <div class="wrapper_div">
              <form class="search_form" action="<c:url value="goods"/>" method="post">
                  <input type="hidden" name="act" value="list_all" size="10"/>
                  <input type="hidden" name="page_no" value=""/>
                  <span>商品名称:</span>
                  <input type="text" name="g_name" value="${param.g_name}" size="10"/>
                  &nbsp;
                  <span>类别编号:</span>
                  <input type="text" name="ctg_no" value="${param.ctg_no}" size="10"/>
                  <input type="submit" value="查 询"/>
              </form>
             <span>(可输入关键字查询)</span>
              <span style="margin-left:50px;">(编号<c:forEach items="${categoryList}" var="category">
                 <c:if test="${category.categoryNo!=0}">${category.categoryNo}:${category.categoryName }</c:if>
              </c:forEach>)</span>
          </div>        
      </div>
      <hr/>
      <table class="listtable">
          <tr>
              <th>商品编号</th>
              <th>商品名称</th>
              <th>商品图片</th>
              <th>商品类别</th>
              <th>商品单价</th>
              <th>库存量</th>
              <th>商品描述</th>
              <th>操作</th>
          </tr>
          <c:forEach items="${page.pageContent}" var="goods">
              <tr>
                  <td>${goods.goodsNo}</td>
                  <td>${goods.goodsName}</td>
                  <td><img alt="商品照片" width="120px" height="90px" src="<c:url value="/goods?act=get_pic&g_no=${goods.goodsNo}"/>"/></td>
                  <td>${goods.categoryNo} ${category.categoryName }</td>
                  <td>${goods.goodsPrice }</td>
                  <td>${goods.cnt}</td>
                  <td>${goods.goodsMemo }</td>
                  <td>
                      <button onclick="javascript:mend('${goods.goodsNo}');">修 改</button>
                      <button onclick="javascript:del('${goods.goodsNo}','${goods.goodsName}');">删 除</button>
                  </td>
              </tr>
          </c:forEach>
      </table>
        <div class="page_infos">
	            共${page.totalRecNum}条, 当前显示${page.startIndex}-${page.endIndex}条, 第${page.pageNo}/${page.totalPageNum}页
	           |
	           <c:if test="${page.pageNo>1}">
	             <span class="linkspan" onclick="doQuery(1)">首页</span>&nbsp;
	           </c:if>
	           <c:if test="${page.prePage}">
	             <span class="linkspan" onclick="doQuery(${page.pageNo-1})">上一页</span>&nbsp;
	           </c:if>
	           <c:if test="${page.nextPage}">
	             <span class="linkspan" onclick="doQuery(${page.pageNo+1})">下一页</span>&nbsp;
	           </c:if>
	           <c:if test="${page.pageNo!=page.totalPageNum}">
	             <span class="linkspan" onclick="doQuery(${page.totalPageNum})">末页</span>&nbsp;
	           </c:if>
	           |
	            到<input type="text" id="pageNo" size=4 style="text-align:right;" onkeypress="onlynumber();"/>页
	        <button onclick="doQuery2();">跳 转</button>         		           	           	              
	  </div>
      <c:if test="${empty page.pageContent}">
          <div class="no_found" style="color:red">
                                    对不起,无法查找到您所要求的商品信息.......
          </div>
      </c:if>
  </body>
</html>
